package com.kingdee.eas.jky.pmt.app;

import java.math.BigDecimal;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.ui.face.UIRuleUtil;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.jky.enums.RLEnum;
import com.kingdee.eas.jky.pmt.BankMoneyBillFactory;
import com.kingdee.eas.jky.pmt.BankMoneyBillInfo;
import com.kingdee.eas.jky.pmt.BankMoneyQrBillInfo;

public class BankMoneyQrBillControllerBean extends AbstractBankMoneyQrBillControllerBean
{
    private static Logger logger =
        Logger.getLogger("com.kingdee.eas.jky.pmt.app.BankMoneyQrBillControllerBean");
    protected void _audit(Context ctx, IObjectPK pk)throws BOSException, EASBizException
    {
         super._audit(ctx, pk);
         BankMoneyQrBillInfo QrBillInfo = (BankMoneyQrBillInfo) this.getValue(ctx, pk);
         String SourceBillId =QrBillInfo.getSourceBillId();
         if(SourceBillId!=null){
        	 BankMoneyBillInfo bankInfo =BankMoneyBillFactory.getLocalInstance(ctx).getBankMoneyBillInfo(new ObjectUuidPK(SourceBillId));
        	 BigDecimal amount=UIRuleUtil.getBigDecimal(bankInfo.getYiskAmount()).add(UIRuleUtil.getBigDecimal(QrBillInfo.getAmount()));
        	 bankInfo.setYiskAmount(amount);
        	 if(bankInfo.getAmount().equals(amount)){
        		 bankInfo.setRlState(RLEnum.yrl);
        	 }else{
        		 bankInfo.setRlState(RLEnum.bf);
        	 }
        	 BankMoneyBillFactory.getLocalInstance(ctx).update(new ObjectUuidPK(SourceBillId), bankInfo);
         }
    }
    protected void _unAudit(Context ctx, IObjectPK pk)throws BOSException, EASBizException
    {
         super._unAudit(ctx, pk);
         BankMoneyQrBillInfo QrBillInfo = (BankMoneyQrBillInfo) this.getValue(ctx, pk);
         String SourceBillId =QrBillInfo.getSourceBillId();
         if(SourceBillId!=null){
        	 BankMoneyBillInfo bankInfo =BankMoneyBillFactory.getLocalInstance(ctx).getBankMoneyBillInfo(new ObjectUuidPK(SourceBillId));
        	 bankInfo.setYiskAmount(UIRuleUtil.getBigDecimal(bankInfo.getYiskAmount()).subtract(UIRuleUtil.getBigDecimal(QrBillInfo.getAmount())));
        	 bankInfo.setRlState(RLEnum.bf);
        	 BankMoneyBillFactory.getLocalInstance(ctx).update(new ObjectUuidPK(SourceBillId), bankInfo);
         }
    }
    protected void _unAudit(Context ctx, IObjectPK[] pks)throws BOSException, EASBizException
    {
         super._unAudit(ctx, pks);
    }
    protected String _getBindingProperty(Context ctx)throws BOSException
    {
        return  super._getBindingProperty(ctx);
    }
    protected void _csh(Context ctx, IObjectValue model)throws BOSException
    {
    }
}